package cn.lvji.springboot.learn3.controller;

import cn.lvji.springboot.learn3.vo.ScenicVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 校验测试
 *
 * @author zhouzx
 */
@Slf4j
@Controller
public class ValidateController {

    @PostMapping("/scenic/validate")
    @ResponseBody
    public String validate(ScenicVO scenicVO, BindingResult result) {
        if (result.hasErrors()) {
            log.error("invalidate datas {}", result.getAllErrors());
            return "invalidate data";
        }
        return "success";
    }
}
